<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui">
	<ui:composition template="/templates/padrao.xhtml">
		<ui:define name="barraTitulo">Cadastro de Combust&iacute;vel</ui:define>
		<ui:define name="conteudo">
			<h:form id="lista" >
				<p:growl id="messages"/>		
				<p:dataTable value="#{controleCombustivel.lista}" 
				             id="id_Lista"
				             var="combustivel" 
				             paginator="true" 
				             rows="10" 
				             dynamic="true" 
							 firstPageLinkLabel="Primeiro"
				             previousPageLinkLabel="Anterior"
				             nextPageLinkLabel ="Pr&oacute;ximo"
				             lastPageLinkLabel="&Uacute;ltima"
				             emptyMessage="Nenhum resgistro encontrado"
				             errorMessage="Ocorreu um erro"	    			             
				             selectionMode="single"
				             rowEditListener="#{controleCombustivel.onEditRow}">
			        <f:facet name="header">
			            <p:commandButton type="button" onclick="dAddCombustivel.show();" value="Adicionar Combust&iacute;vel" image="add"/>  
			        </f:facet>
					<p:column sortBy="#{combustivel.codigoCombustivel}" filterBy="#{combustivel.codigoCombustivel}" headerText="C&oacute;digo" resizable="true" style="width:30px" >
						<p:cellEditor>
	                        <f:facet name="output">  
	                            <h:outputText value="#{combustivel.codigoCombustivel}" />  
	                        </f:facet>  
	                        <f:facet name="input">  
	                        	<h:outputText value="#{combustivel.codigoCombustivel}" />   
	                        </f:facet> 
						</p:cellEditor>
					</p:column>
					<p:column sortBy="#{combustivel.descricao}" filterBy="#{combustivel.descricao}" headerText="Descri&ccedil;&atilde;o" resizable="true" >
						<p:cellEditor>
	                        <f:facet name="output">  
	                            <h:outputText value="#{combustivel.descricao}" />  
	                        </f:facet>  
	                        <f:facet name="input">  
	                        	<p:inputText value="#{combustivel.descricao}" />  
	                        </f:facet>
						</p:cellEditor>
					</p:column>
					<p:column resizable="true" styleClass="width80">
						<p:rowEditor />
						<p:commandLink update="lista" oncomplete="dlg.show();">  
							<h:graphicImage url="/images/marcadores/excluir.png" alt="Excluir Combust&iacute;vel"/>  
							<f:setPropertyActionListener target="#{controleCombustivel.combustivel}" value="#{combustivel}" />
						</p:commandLink>
                    </p:column>
				</p:dataTable>
				<!-- DIALOG EXCLUSAO -->
				<p:dialog header="Confirma&ccedil;&atilde;o" width="300" fixedCenter="true" widgetVar="dlg" visible="false">  
					<h:panelGrid columns="2" style="margin-bottom:10px">
						<h:column>   
							<h:outputLabel  value="Deseja Excluir?" />
						</h:column>
						<h:column >
							<p:commandButton value="Sim" action="#{controleCombustivel.excluir}" update="id_Lista" oncomplete="dlg.hide();" />  
							<p:commandButton value="Nao" update="form" oncomplete="dlg.hide();"/>
						</h:column>  
					</h:panelGrid>  
				</p:dialog>
			</h:form>
			<!-- DIALOG INCLUSAO COMBUSTIVEL -->
			<p:dialog header="Incluir Combustivel" fixedCenter="true" width="350" widgetVar="dAddCombustivel" visible="false" modal="true"> 
				<h:form id="formAddCombustivel" >
					<h:panelGrid columns="2" columnClasses="width150 alinhaDir, width200">
						<h:outputText value="Descri&ccedil;&atilde;o:" styleClass=""/>
						<h:inputText  value="#{controleCombustivel.combustivel.descricao}" requiredMessage="Campo [DESCRICAO] obrigat&oacute;rio"/>
					</h:panelGrid>
					<h:commandLink action="#{controleCombustivel.limpar}">
						<h:graphicImage url="/images/botoes/btnLimpar.png" class="btnAcoes"/>
					</h:commandLink>
					<h:commandLink action="#{controleCombustivel.gravar}" styleClass="alinhaDir">
						<h:graphicImage url="/images/botoes/btnGravar.png" class="btnAcoes"/>
					</h:commandLink>
				</h:form>
			</p:dialog>
		</ui:define>
	</ui:composition>
</html>